package com.japher.hackson.requests;

import com.baidu.common.async_http.AbstractParser;
import com.baidu.common.async_http.AbstractRequester;
import com.baidu.common.json.JsonSerializer;
import com.baidu.common.net.HttpRequestData;
import com.baidu.common.utils.AppLog;
import com.japher.hackson.response.BaseResponse;
import com.japher.hackson.response.CommentResponse;
import com.japher.hackson.response.DetailInfoResponse;

public class LoadDetailRequest extends AbstractRequester{

    public String id;
    public LoadDetailRequest(String id){
        this.id = id;
    }
    
    @Override
    protected HttpRequestData createSendData() {
        HacksonReuqestData data = new HacksonReuqestData(HacksonReuqestData.BASE_URL  + "/essay/"+id);
        data.setAppUrl(false);
        data.setSecurity(false);
        data.setGzip(false);
        
        
        return data;
    }

    @Override
    protected AbstractParser createParser() {
        return new DetailInfoParser();
    }
    
    
    public static final class DetailInfoParser extends AbstractParser{

        @Override
        protected AbstractParser createParser() {
            return null;
        }

        @Override
        protected BaseResponse jsonParse(String json) {
            // TODO Auto-generated method stub
            AppLog.debug(this, json);
            BaseResponse res = JsonSerializer.getInstance().deserialize(json, DetailInfoResponse.class);
            if (res == null) {
                res = new BaseResponse();
                res.setStatus(BaseResponse.ERR_CODE_JSON_PARSE);
            }
            return res;
        }
        
    }
}
